package com.dubbo.filter;

import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * Created by Administrator on 2020/6/28 0028.
 */
// @Activate 无条件自动激活
@Activate
public class DubboLogFilter implements Filter{
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        Result rs = null;
        try {
            String clientIp = RpcContext.getContext().getRemoteHost();
            rs = invoker.invoke(invocation);
            System.out.println("远程地址ip"+clientIp);
        }catch (Exception e) {
            // TODO: handle exception
        }
        return rs;
    }
}
